home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #6
/
Amiga Plus CD - 2004 - No. 06.iso
/
AmigaPlus
/
Tools
/
Dev_Libs
/
Amiblitz2
/
thilo_includes
/
dbl_benchmark.ab2
< prev
next >
Wrap
Text File
|
2003-02-13
|
5KB
|
155 lines
optimize 7
Syntax 2
WBStartup
!error_include
!dbl_include ;1,1 best For gfx card and if you want scrolling
;!dbl_include 0,0 ;best for AGA AND workbench games
#scrl = 0 ; scroll background
maxdepth.l = 1 ; max depth of screen
NEWTYPE.ball
x.q
y.q
xs.q
ys.q
End NEWTYPE
Dim List ball.ball(0)
ballcounter.l = 0
message.s = ""
succ.l = False
balltyp.l = 3
breakme.l = False
scrl.l = False
Statement newmessage {}
SHARED ball(),ballcounter,message.s,balltyp,ballsize.l,ballshot.l
Format ""
If balltyp=2 Then a.s = "64x64"
If balltyp=3 Then a.s = "32x32"
If balltyp=4 Then a.s = "16x16"
message.s = "balls: "+Str$(ballcounter)+" / size: "+a.s+" / fps: "
Format "000.00"
End Statement
Statement ball_add {}
SHARED ball(),ballcounter,message.s,balltyp,width.l,height.l
If AddItem(ball())
ball()\x=Rnd(width),Rnd(height),(Rnd-.5)*20+1,(Rnd-.5)*20+1
ballcounter+1
End If
newmessage {}
End Statement
Statement ball_remove {}
SHARED ball(),ballcounter,message.s,balltyp
ResetList ball()
If NextItem(ball())
KillItem ball():ballcounter-1
End If
newmessage {}
End Statement
path.s = "gfx/" ; set your path here, including "/" !
!screen_ {0,"test","ram:test",3}
width.l=!screen_width:height.l=!screen_height
If dbl_init {"MyGame",!screen_id,width,height,!screen_depth}
dbl_showpointer{}
dbl_setpen {1,144,144,144} ; set pen 1 so that we can see error messages
If image_load {1,path.s+"pattern"}
dbl_bgblitpattern{1,0,0,width,height} ; blit the background pattern in window
succ=image_load {2,path.s+"ball64x64",0} ; set path above
succ&image_load {3,path.s+"ball32x32",0}
succ&image_load {4,path.s+"ball16x16",0}
image_midhandle {2}
image_midhandle {3}
image_midhandle {4}
If succ
count.l = 0
res.q = 50
While breakme=False
res=Timer:ResetTimer:If res=0 Then res=1
ev.l = Event
While ev = #IDCMP_VANILLAKEY
Select EventCode
Case 27
breakme = True
Case 97
ball_add{}
Case 114
ball_remove{}
Case 115
scrl=1-scrl
sxv.q= Rnd*2 * Sgn(Rnd-.5):syv.q=Rnd*2 * Sgn(Rnd-.5)
Case 99
balltyp+1:If balltyp=5 Then balltyp=2
newmessage {}
Case 109
If imagedat(2)\mask_ptr
FreeMem imagedat(2)\mask_ptr,0 : imagedat(2)\mask_ptr = False
FreeMem imagedat(3)\mask_ptr,0 : imagedat(3)\mask_ptr = False
FreeMem imagedat(4)\mask_ptr,0 : imagedat(4)\mask_ptr = False
Else
image_initmask{2,0}
image_initmask{3,0}
image_initmask{4,0}
End If
End Select
ev.l = Event
Wend
If scrl
scroll_x.l - sxv.q
scroll_y.l - syv.q
dbl_bgscroll{sxv.q,syv.q}
If sxv<0
dbl_bgblitpattern{1,0,0,-sxv,height,scroll_x,scroll_y}
Else
dbl_bgblitpattern{1,width-1-sxv,0,sxv,height,scroll_x,scroll_y}
End If
If syv<0
dbl_bgblitpattern{1,0,0,width,-syv,scroll_x,scroll_y}
Else
dbl_bgblitpattern{1,0,height-1-syv,width,syv,scroll_x,scroll_y}
End If
End If
dbl_flip{} ; flip the doublebuffer !
dbl_unqueue{} ; unblit all objects drawn with "dbl_q???" commands
ResetList ball()
If Joyb(0)=1 Then fireval.l+1:Else fireval=0
While NextItem(ball())
If dbl_2imghit {balltyp,ball()\x,ball()\y,@@
-1,SMouseX,SMouseY}@@ ;@@ mean join next line to term
AND (fireval > 0 AND fireval < 2);last value increase for MG depend on magazine size
KillItem ball():ballcounter-1
ballshot+1
Else
ball()\x+ball()\xs*correctspeed.l
ball()\y+ball()\ys*correctspeed
If ball()\x<0 OR ball()\x>width Then ball()\xs=-ball()\xs
If ball()\y<0 OR ball()\y>height Then ball()\ys=-ball()\ys
dbl_qblit {balltyp,ball()\x,ball()\y} ;draw balls
End If
Wend
dbl_qprint {message.s+Str$(50/res)+" Score "+Str$(ballshot),10,10,2} ; Print a text for 1 frame
;dbl_qprint {message.s+Str$(1000/res),10,10,2} ; Print a text for 1 frame
dbl_qprint {"ESC=exit (a)dd ball (r)emove ball (c)hange Type (m)ask Toggle (s)croll",10,height-16,2}
;count.l+1:If count=20 Then count=0:res=Timer:ResetTimer:If res=0 Then res=1
loop If Timer<1 Then Goto loop ;need for framerate limit
correctspeed.l=Timer ;need for same speed regardless on framerate
Wend
End If
End If
End If
End ;important allow autofree